package cn.wolfcode.enums;

import lombok.Getter;

@Getter
public enum AppointmentStatusEnum {
    /*枚举需要用的是,隔开*/
    PEND("待确认", 0),

    PERFORM("履行中",1),

    CONSUME("消费中",2),

    FINISH("归档",3),

    PAILURE("废弃",4);

    private Integer value;
    private String name;

    //枚举类的构造器本来就是私有的
    private AppointmentStatusEnum(String name, Integer value) {
        this.name = name;
        this.value = value;
    }
    public static String findName(Integer value){
        //获取所有的枚举常量，然后遍历并返回它的name
        AppointmentStatusEnum[] values = AppointmentStatusEnum.values();
        //所有的枚举常量
        for (AppointmentStatusEnum appointmentStatusEnum : values) {
            //判断如果传入的枚举常量值等于某一个枚举常量值，则将其名字返回
            if (appointmentStatusEnum.getValue().equals(value)){
                return appointmentStatusEnum.getName();
            }
        }
        return null;
    }
}
